home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 9
/
FM Towns Free Software Collection 9.iso
/
t_os
/
tool
/
cdplayer
/
cd_src
/
cdplay.c
< prev
next >
Wrap
Text File
|
1994-11-16
|
2KB
|
95 lines
#include <stdio.h>
#include <snd.h>
#include <stdlib.h>
#include <cdrfrb.h>
#include <fmcfrb.h>
#include "cd_sub.h"
/* プロトタイプ宣言 */
void error(int ret);
int key_in();
void disp_stat(int no, struct TIMEADRS *time1, struct TIMEADRS *time2);
/* グローバル変数宣言 */
struct TIMEADRS dsktime;
struct TIMEADRS trktime[99];
int type,strack,etrack;
int ptrack;
/* メイン関数 */
void main()
{
int ret;
VDB_init();
VDB_setcusmd(1);
SND_elevol_init();
SND_elevol_set(1,127,127);
SND_elevol_mute(0x0030);
cd_stop();
ret = cd_info(&type, &strack, &etrack, trktime, &dsktime);
if(ret !=0) {
error(ret);
exit(1);
}
printf("Start track =%d\n",strack);
printf("End track =%d\n",etrack);
printf("%2d:%2d:%2d", dsktime.min, dsktime.sec, dsktime.frame);
while (1) {
ret = key_in();
}
}
int key_in()
{
static int sw = 1, no, stat;
static unsigned int code, encode;
static struct TIMEADRS rdsktime;
static struct TIMEADRS rdtime;
int ret;
cd_stat(&stat, &no, &rdtime, &rdsktime);
disp_stat(no, &rdtime, &rdsktime);
code = KYB_read(sw, &encode);
switch(code) {
case 'p':
case 'P':
if(type == 1) ret = cd_play(strack+1, &dsktime, trktime);
else ret = cd_play(strack+1, &dsktime, trktime);
if(ret != 0) error(ret);
break;
case 'n':
case 'N':
if(no != etrack) cd_play(no+1, &dsktime, trktime);
break;
case 'b':
case 'B':
if((type == 1 && no > 1) || (type != 1 && no > 2)) {
cd_play(no-1, &dsktime, trktime);
}
break;
case 's':
case 'S':
cd_stop();
break;
case 'e':
case 'E':
VDB_setcusmd(0);
exit(0);
}
return(0);
}
void disp_stat(int no, struct TIMEADRS *time1, struct TIMEADRS *time2)
{
VDB_setposcus(10, 4);
printf("%2d %2d:%2d:%2d",no ,time1->min, time1->sec, time1->frame);
VDB_setposcus(10, 5);
printf(" %2d:%2d:%2d",time2->min, time2->sec, time2->frame);
}
void error(int ret)
{
printf("error!! no=%x",ret);
}